<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //定义一个含有30个整型元素的数组，按顺序分别赋予从2开始的偶数；然后按顺序每五个数求出一个平均值，放在另一个数组中并输出。试编程。
        let arrInt = [];
        let newArrInt = [];
        let temp = 0;
        arrInt.length = 30;
        for (let i = 0; i < arrInt.length; i++) {
            arrInt[i] = i * 2 + 2;
            temp = temp + arrInt[i];
            if ((i + 1) % 5 == 0) {
                newArrInt.push(temp / 5);
                temp = 0;
            }
        }
        console.log(newArrInt)

        //编写函数getobj(arr) 统计数字出现的次数。
        let arr = ["a", "a", "b", "c", "b"];
        let str = '';
        function getobj(arr) {
            let temp = [];
            for (var i = 0; i < arr.length; i++) {
                if (temp.indexOf(arr[i]) === -1) {
                    temp.push(arr[i])
                }
            }
            for (let i = 0; i < temp.length; i++) {
                let j = 0
                while (arr.indexOf(temp[i]) !== -1) {
                    arr.splice(arr.indexOf(temp[i]), 1)
                    j++;
                }
                str += `-${temp[i]}有${j}个-`
            }
            return str; // {a:2,b:2,c:1}
        }
        console.log(getobj(arr))

        //编写函数，判断一个字符串是否是 “可回文字符串”
        let strTwo = '你好世界世好你';
        function getBoo(str) {
            let temp = str.split('').reverse().join('');
            return temp == str ? true : false
        }
        console.log(getBoo(strTwo))

    </script>
</body>

</html>